package com.netbao.sys.vomapper;

import com.netbao.testeasypoi.Person;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.StatementType;

import java.util.List;
import java.util.Map;

/**
 * @author zhouxp
 * @create 2019-08-11 10:54
 */
public interface PersonMapper {
	@Insert("insert into t_person1(name,sex,birthday,state) values(#{name},#{sex},#{birthday},#{state})")
	void insert(Person person);

	@Select("select * from t_person")
	List<Person> getAll();
	@Insert("<script>INSERT INTO t_person1(name,sex,birthday,state) VALUES\n" +
			"<foreach collection =\"list\" item=\"person\" separator =\",\">\n" +
			"\t(#{person.name}, #{person.sex}, #{person.birthday}, #{person.state})\n" +
			"</foreach></script>")
	void insertBatch(List<Person> persons);

	@Delete("delete from t_person1")
	void delete();

	@Select("call p_check(#{reuslt,mode=OUT,jdbcType=INTEGER})")
	@Options(statementType = StatementType.CALLABLE)
	void check(Map<String, Object> map);

	@Select("select * from t_person1")
	List<Person> geterror();

}
